import { Component, OnInit } from '@angular/core';
import { NzModalService } from 'ng-zorro-antd';

declare var form: any;

@Component({
  templateUrl: './map.style.html'
})
export class MapStyleComponent implements OnInit {
  fs: any = null;
  ffs: any = null;
  sideDic: any = null;
  browserDic: any = null;
  terminalDic: any = null;

  constructor(private modalService: NzModalService) {
    this.fs = new form.FormSideSimpleService('styles', {
      orderObject: { order: 0 },
      keyField: 'id',
      randomFields: ['id'],
      foreignKey: 'styleId'
    });

    this.ffs = new form.FileService();

    this.fs.loadData(true);

    // 方案表单字典
    this.sideDic = new form.DictionaryService('p_style_directory');
    this.sideDic.loadAll();

    // 浏览器类型字典
    this.browserDic = new form.DictionaryService('d_browser');
    // 终端类型字典
    this.terminalDic = new form.DictionaryService('d_terminal');
  }

  // 重写编辑方法，做编辑跳转，新增则传false即可
  editRow(item) {
    const fk = this.fs.foreignValue;
    if (!fk || fk === '') {
      this.modalService.success({
        nzTitle: '系统提示',
        nzContent: '请选择一个地图方案!'
      });
      return;
    }
    if (item) {
      window.open('#data_styleinfo_mis?info=true&sid=' + fk + '&id=' + item.id);
    } else {
      window.open('#data_styleinfo_mis?info=true&sid=' + fk);
    }
  }

  ngOnInit(): void {

  }
}
